package com.example.springbootprodb.controller.impl;

import com.example.springbootprodb.controller.DeptController;
import com.example.springbootprodb.entity.Dept;
import com.example.springbootprodb.entity.Result;
import com.example.springbootprodb.service.impl.DeptServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 路老师
 * @date 2025/4/9
 * 无精神，不编程！无乐趣，不编程！
 * “调试：与bug共舞的艺术。”
 * 控制层：响应用户的获取表中所有数据的请求
 */
@RestController
public class DeptControllerImpl implements DeptController {

    @Autowired
    DeptServiceImpl deptService;

    @GetMapping("/dept")
    @Override
    public Result list() {
        List<Dept> depts = deptService.listService();
        return Result.success(depts);
    }

    @DeleteMapping("/del/{id}")
    @Override
    public Result del(@PathVariable Integer id) {
        deptService.delService(id);
        return Result.success();
    }
}
